from building import *

cwd = GetCurrentDir()
src = Glob('*.c')
CPPPATH = []

if GetDepend('SUPPORT_AD'):
    CPPPATH.append(cwd + '/AD')
    if GetDepend('SUPPORT_AD_ASM32F0'):
      src += Glob('AD/AD_ASM32.c')
    elif GetDepend('SUPPORT_AD_HC32F4'):  
      src += Glob('AD/AD_HC32F4.c')   
    elif GetDepend('SUPPORT_AD_HC32F4_DUAL'):  
      src += Glob('AD/AD_dHC32F4.c')  
    elif GetDepend('SUPPORT_AD_STM32G0XX'):  
      src += Glob('AD/AD_STM32G0xx.c') 
    if GetDepend('SUPPORT_AD_SMENU'):
      src += Glob('AD/AD_SMenu.c')

if GetDepend('SUPPORT_ADC'):
    CPPPATH.append(cwd + '/ADC')
    if GetDepend('SUPPORT_ADC_HC32F4'):   
      src += Glob('ADC/ADC_HC32F4.c') 

if GetDepend('SUPPORT_ADLER32'):
    CPPPATH.append(cwd + '/Adler32')
    src += Glob('Adler32/Adler32.c') 

if GetDepend('SUPPORT_ADR_HW'):
    CPPPATH.append(cwd + '/Adr')
    src += Glob('Adr/AdrHw.c') 
    if GetDepend('SUPPORT_ADR_HW_HC32F0'):   
      src += Glob('Adr/Adr_cbHC32F0.c') 
    elif GetDepend('SUPPORT_ADR_HW_STM32F1'):   
      src += Glob('Adr/Adr_cbSTM32F1x.c') 

if GetDepend('SUPPORT_AT_USART'):
    CPPPATH.append(cwd + '/AtUsart')
    src += Glob('AtUsart/AtUsart.c') 
    if GetDepend('SUPPORT_AT_CMD'):
        src += Glob('AtUsart/AtCmd.c') 

if GetDepend('SUPPORT_B_READER'):
    CPPPATH.append(cwd + '/bReader')
    src += Glob('bReader/bReader.c') 

if GetDepend('SUPPORT_BUS_BASE'):
    CPPPATH.append(cwd + '/BusBase')
    src += Glob('BusBase/BusCount.c') 
    if GetDepend('SUPPORT_BUS_MOUNT'):
      src += Glob('BusBase/BusMount.c') 
    if GetDepend('SUPPORT_BUS_BASE_SMENU'):
      src += Glob('BusBase/BusCount_SMenu.c')
    if GetDepend('SUPPORT_BUS_BASE_TMENU'):
      src += Glob('BusBase/BusCount_TMenu.c') 

if GetDepend('SUPPORT_BUS_BUAD_CAL'):
    CPPPATH.append(cwd + '/BusBuadCal')
    src += Glob('BusBuadCal/BusBuadCal.c')
    if GetDepend('SUPPORT_BUS_BUAD_CAL_SMENU'):
      src += Glob('BusBuadCal/BusBuadCal_SMenu.c')

if GetDepend('SUPPORT_BUS_PRINTER') and GetDepend('SUPPORT_BUS_BASE'):
    CPPPATH.append(cwd + '/BusPrinter')
    src += Glob('BusPrinter/BusPrinter.c')
    if GetDepend('SUPPORT_BUS_PRINTER_TMENU'):
      src += Glob('BusPrinter/BusPrinter_TMenu.c')
    if GetDepend('SUPPORT_PRINTER_CMD'):
      src += Glob('BusPrinter/BusPrinter_cbPrintCmd.c') 

if GetDepend('SUPPORT_BUS_PROTOCOL'):
    CPPPATH.append(cwd + '/BusProtocol')
    src += Glob('BusProtocol/BusProtocol.c')
    if GetDepend('SUPPORT_BUS_PROTOCOL_TMENU'):
        src += Glob('BusProtocol/BusProtocol_TMenu.c')

if GetDepend('SUPPORT_BUS_SLV_USART') and GetDepend('SUPPORT_BUS_BASE'):
    CPPPATH.append(cwd + '/BusSlvUsart')
    src += Glob('BusSlvUsart/BusSlvUsart.c')

if GetDepend('SUPPORT_CODE'):
    CPPPATH.append(cwd + '/Code')
    src += Glob('Code/Code.c')
    if GetDepend('SUPPORT_GB2312_UCS2'):
        src += Glob('Code/GB2312_UCS2.c')
        src += Glob('Code/UCS2ToGB2312.c')        
    if GetDepend('SUPPORT_GB2312_UTF8'):
        src += Glob('Code/GB2312_Utf8.c')    
    if GetDepend('SUPPORT_UNICODE_UTF8'):
        src += Glob('Code/Unicode_Utf8.c')               

if GetDepend('SUPPORT_DA'):
    CPPPATH.append(cwd + '/DA')
    if GetDepend('SUPPORT_DA_ADJ'):
        src += Glob('DA/DA_Adj.c')
        if GetDepend('SUPPORT_DA_ADJ_SMENU'):
            src += Glob('DA/DA_Adj_SMenu.c')
        elif GetDepend('SUPPORT_DA_ADJ_QMENU'):
            src += Glob('DA/DA_AdjQMenu.c')
    if GetDepend('SUPPORT_DA_PWM_ASM32'):
        src += Glob('DA/DA_PWM_ASM32.c')
    elif GetDepend('SUPPORT_DA_PWM_AVR'):
        src += Glob('DA/DA_PWM_Avr.c') 
    elif GetDepend('SUPPORT_DA_PWM_HC32F4'):
        src += Glob('DA/DA_PWM_HC32F4.c')  
    elif GetDepend('SUPPORT_DA_PWM_HC32'):
        src += Glob('DA/DA_PWM_HC32.c')           
    elif GetDepend('SUPPORT_DA_PWM_PIC'):
        src += Glob('DA/DA_PWM_PIC.c')   
    elif GetDepend('SUPPORT_DA_STM32'):
        src += Glob('DA/DA_Stm32.c') 

if GetDepend('SUPPORT_DA8'):
    CPPPATH.append(cwd + '/DA')
    if GetDepend('SUPPORT_DA8_ADJ'):
        src += Glob('DA/DA8Adj.c')
        if GetDepend('SUPPORT_DA8_ADJ_SMENU'):
            src += Glob('DA/DA_Adj_SMenu.c')
    if GetDepend('SUPPORT_DA8_PWM_ASM32PCA'):
        src += Glob('DA/DA8_PWM_ASM32PCA.c') 
    elif GetDepend('SUPPORT_DA8_PWM_HC32F4A'):
        src += Glob('DA/DA_PWM_HC32F4A.c')  

if GetDepend('SUPPORT_DA_FROM_VOL'):
    CPPPATH.append(cwd + '/DaFromVol')
    src += Glob('DaFromVol/DaFromVol.c')

if GetDepend('SUPPORT_DA_STREAM'):
    CPPPATH.append(cwd + '/DaStream')
    src += Glob('DaStream/DaStream.c')
if GetDepend('SUPPORT_DA_STREAM_SWM341'):
    src += Glob('DaStream/DaStream_SWM341.c')
if GetDepend('SUPPORT_DA_STREAM_EXAMPLE1'):
    src += Glob('DaStream/DaStream_Example1.c')
elif GetDepend('SUPPORT_DA_STREAM_EXAMPLE2'):
    src += Glob('DaStream/DaStream_Example2.c')
    src += Glob('DaStream/DaStream_Instance.c')
elif GetDepend('SUPPORT_DA_STREAM_EXAMPLE3'):
    src += Glob('DaStream/DaStream_Example3.c')
    src += Glob('DaStream/DaStream_Instance.c')

if GetDepend('SUPPORT_DEFLATE_NANO'):
    CPPPATH.append(cwd + '/DeflateNano')
    src += Glob('DeflateNano/DeflateNano.c')

if GetDepend('SUPPORT_ESP8266'):
    CPPPATH.append(cwd + '/ESP8266')
    src += Glob('ESP8266/ESP8266.c')
    src += Glob('ESP8266/ESP8266_Init.c')
    src += Glob('ESP8266/ESP8266_Pass.c') 
    if GetDepend('SUPPORT_ESP8266SC'):
        CPPPATH.append(cwd + '/ESP8266Sc')
        CPPPATH.append(cwd + '/ESP8266ScAT')    

if GetDepend('SUPPORT_GRP_PACKET'):
    CPPPATH.append(cwd + '/GrpPacket')
    src += Glob('GrpPacket/GrpPacket.c')

if GetDepend('SUPPORT_HAFFMAN_TREE'):
    CPPPATH.append(cwd + '/HuffmanTree')
    src += Glob('HuffmanTree/HuffmanTree.c')    

if GetDepend('SUPPORT_IPV4_CFG'):
    CPPPATH.append(cwd + '/IPv4Cfg')
    src += Glob('IPv4Cfg/IPv4Cfg.c')    
    if GetDepend('SUPPORT_IPV4_CFG_QMENU'):
        CPPPATH.append(cwd + '/IPv4Cfg/QMenu')
        src += Glob('IPv4Cfg//QMenu/MEnu_IPv4Cfg.c')   

if GetDepend('SUPPORT_LRC'):
    CPPPATH.append(cwd + '/LRC')
    src += Glob('LRC/LRC.c')

if GetDepend('SUPPORT_M_DA'):
    CPPPATH.append(cwd + '/mDA')
    src += Glob('mDA/Da_Mng.c')
    if GetDepend('SUPPORT_M_DA_ADJ'):
        src += Glob('mDA/DA_Adj.c')
        if GetDepend('SUPPORT_M_DA_ADJ_SMENU'):
            src += Glob('mDA/DA_Adj_SMenu.c')
        if GetDepend('SUPPORT_M_DA_ADJ_QMENU'):
            src += Glob('mDA/DA_AdjQMenu.c')
    if GetDepend('SUPPORT_M_DA_PWM_HC32F4'):
        src += Glob('mDA/DA_PWM_HC32F4.c')  

if GetDepend('SUPPORT_M_DA8'):
    CPPPATH.append(cwd + '/mDA8')
    if GetDepend('SUPPORT_M_DA8_ADJ '):
        src += Glob('mDA/DA8_Adj.c')
        if GetDepend('SUPPORT_M_DA8_ADJ_SMENU'):
            src += Glob('mDA/DA8_Adj_SMenu.c')
    if GetDepend('SUPPORT_DA8_PWM_HC32F4A'):
        src += Glob('mDA8/DA_PWM_HC32F4A.c')  

if GetDepend('SUPPORT_MODBUS_CODEC'):
    CPPPATH.append(cwd + '/ModbusCodec')
    src += Glob('ModbusCodec/ModbusCodec.c')

if GetDepend('SUPPORT_MODBUS_CRC') or GetDepend('SUPPORT_MODBUS_RTU_MNG'):
    CPPPATH.append(cwd + '/ModbusRtuMng')
    if GetDepend('SUPPORT_MODBUS_RTU_MNG'):
        src += Glob('ModbusRtuMng/ModbusRtuMng.c') 
        if GetDepend('SUPPORT_MODBUS_RTU_MNG_QMENU'):
            src += Glob('ModbusRtuMng/ModbusRtuMngQMenu.c') 
    if GetDepend('SUPPORT_MODBUS_CRC'):
        src += Glob('ModbusRtuMng/ModbusRtuMng_CRC.c')  

if GetDepend('SUPPORT_MQTT'):
    CPPPATH.append(cwd + '/Mqtt')
    src += Glob('Mqtt/MqttMng.c')
    src += Glob('Mqtt/MqttUser.c')
    src += Glob('Mqtt/MqttUserAT.c')

if GetDepend('SUPPORT_MSG_PACKET_Q'):
    CPPPATH.append(cwd + '/MsgPacketQ')
    src += Glob('MsgPacketQ/MsgPacketQ.c')

if GetDepend('SUPPORT_PRINTER'):
    CPPPATH.append(cwd + '/Printer')
    if GetDepend('SUPPORT_PRINTER_CMD'):
        src += Glob('Printer/PrinterCmd.c')
    if GetDepend('SUPPORT_PRINTER_CMD_SPRT'):
          src += Glob('Printer/PrinterStdCmd_SPRT.c')
          src += Glob('Printer/PrinterCmd_SPRT.c')

if GetDepend('SUPPORT_SHA256'):
    CPPPATH.append(cwd + '/SHA256')
    src += Glob('SHA256/SHA256_unstd.c')
    src += Glob('SHA256/SHA256_ctx.c')

if GetDepend('SUPPORT_SPI3_MIO'):
    CPPPATH.append(cwd + '/Spi3mio')
    src += Glob('Spi3mio/Spi3mio.c')

if GetDepend('SUPPORT_STR_DEF_PARSER'):
    CPPPATH.append(cwd + '/StrDefParser')
    src += Glob('StrDefParser/StrDefParser.c')

if GetDepend('SUPPORT_TI_COMM_MNG'):
    CPPPATH.append(cwd + '/TiCommMng')
    src += Glob('TiCommMng/TiCommMng_UsartTiny.c')
elif GetDepend('SUPPORT_TI_COMM_MNG_M'):
    CPPPATH.append(cwd + '/TiCommMngM')
    src += Glob('TiCommMngM/TiCommMng.c')

if GetDepend('SUPPORT_USART_TINY'):
    CPPPATH.append(cwd + '/UsartTiny') 
    if GetDepend('SUPPORT_USART_TINY_DEV'):
        src += Glob('TiCommMng/UsartTiny_DevS.c')
    elif GetDepend('SUPPORT_USART_PIC_U'):
        src += Glob('UsartTiny_PicU')   
    elif GetDepend('SUPPORT_USART_PIC_U1'):
        src += Glob('UsartTiny_PicU1')    
elif GetDepend('SUPPORT_USART_TINY_M'):
    CPPPATH.append(cwd + '/UsartTinyM') 
    src += Glob('UsartTinyM/UsartTiny.c')

if GetDepend('SUPPORT_WIN_WRITER'):
    CPPPATH.append(cwd + '/WinWriter')
    src += Glob('WinWriter/WinWriter.c')

if GetDepend('SUPPORT_ZLIB_DECOMPRESS'):
    CPPPATH.append(cwd + '/ZlibDecompress')
    src += Glob('ZlibDecompress/ZlibDecompress.c')

#增加SUPPORT_EX_PREINCLUDE定义以预包含Preinclude.h
predefine = ['SUPPORT_EX_PREINCLUDE']
group = DefineGroup('CompComm', src, depend = [''], CPPPATH=CPPPATH, CPPDEFINES = predefine)
Return('group')
